/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.garethc.creational.builder.factory;

import com.garethc.creational.builder.model.MealOrder;

/**
 *
 * @author 210053429
 */
public class MealBuilder {
    
    
    public static class Builder
    {
        private String burger;
        // optional
        private String drink;
        private String iceCream;
        private String chips;
        private String toy;

        public Builder(String burger) {
            this.burger = burger;
        }
        
        public Builder drink (String drink)
        {
            this.drink = drink;
            return this;
        }
        
        public Builder iceCream (String iceCream)
        {
            this.iceCream = iceCream;
            return this;
        }
        
        public Builder chips (String chips)
        {
            this.chips = chips;
            return this;
        }
        
        public Builder toy (String toy)
        {
            this.toy = toy;
            return this;
        }
        
        public MealOrder build()
        {
            return getMealOrder(this);
        }

        private MealOrder getMealOrder(Builder builder) 
        {
            MealOrder mealOrder = new MealOrder();
            mealOrder.setBurger(builder.burger);
            mealOrder.setChips(builder.chips);
            mealOrder.setDrink(builder.drink);
            mealOrder.setIceCream(builder.iceCream);
            mealOrder.setToy(builder.toy);
            return mealOrder;
        }
    }
}
